<template>
	<view>
		<view class="container">
			<view class="swiper">
				<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000"
					indicator-active-color="pink" style="height: 800rpx;">
					<swiper-item v-for="item in swiperList" :key="item.id">
						<view class="swiper-item">
							<image :src="item.iurl" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<view class="content">
				<view>Welcome to</view>
				<view>奶茶点餐</view>
				<view>源自你的美</view>
			</view>
			<view class="btn">
				<button @click="toLoginPage">登录</button>
				<button @click="toRegisterPage">注册</button>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		queryImageByType
	} from "@/api/index.js"
	export default {
		data() {
			return {
				swiperList: []
			}
		},
		onShow() {
			this.getSwiperList()
		},
		methods: {
			getSwiperList() {
				queryImageByType(1).then(res => {
					this.swiperList = res.data
				})
			},
			toLoginPage() {
				uni.navigateTo({
					url: "../login/login"
				})
			},
			toRegisterPage() {
				uni.navigateTo({
					url: "../register/register"
				})
			}
		}
	}
</script>

<!-- scoped 局部生效，只在当前页生效 -->
<style scoped>
	.swiper-item {
		height: 100%;
	}

	.swiper-item image {
		width: 100%;
		height: 100%;
	}

	.content {
		/* 页面宽度分为了750份,1份就是1rpx,好处就是布局方便 */
		padding: 30rpx;
		/* 元素的总高度和宽度包含内边距和边框 */
		box-sizing: border-box;
	}

	.content view:nth-child(1),
	.content view:nth-child(3) {
		font-weight: bold;
		font-size: 30rpx;
		color: pink;
	}

	.content view:nth-child(2) {
		color: #67C23A;
		font-size: 56rpx;
		margin-top: 30rpx;
		margin-bottom: 30rpx;
	}

	.btn button {
		width: 80%;
		font-weight: bold;
		border-radius: 10px;

	}

	.btn button:nth-child(1) {
		background: #409EFF;
		color: #fff;
	}

	.btn button:nth-child(2) {
		margin-top: 30rpx;
		background: #67C23A;
		color: #fff;
	}
</style>